#
# @lc app=leetcode.cn id=242 lang=python3
#
# [242] 有效的字母异位词
#

# @lc code=start
class Solution:
    def isAnagram(self, s: str, t: str) -> bool:
        # 比较元素集合，再比较字符串中元素出现次数
        if len(s) != len(t): return False
        sts = set(s)
        if sts == set(t):
            for c in sts:
                if s.count(c) != t.count(c): return False
            return True
        else:
            return False
        

            
# @lc code=end

